﻿
    using Chain.BLL;
    using Chain.Model;
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public partial class ExtraParameter : PageBase
    {
 

        protected void BindParameter()
        {
            this.chkSms.Checked = base.curParameter.bolSms;
            this.chkMoneySms.Checked = base.curParameter.bolMoneySms;
            this.chkIsSmsShopName.Checked = base.curParameter.bolIsSmsShopName;
            this.txtSmsShopName.Text = base.curParameter.strSmsShopName;
            this.txtNotificationSMS.Text = base.curParameter.strNotificationSMS;
            this.lblNotificationSMSPwd.Text = base.curParameter.strNotificationSMSPwd;
            this.chkTel.Checked = base.curParameter.bolTel;
            this.chkTelNoMember.Checked = base.curParameter.bolTelNoMember;
            this.chkMMS.Checked = base.curParameter.bolMMS;
            this.txtMMSSeries.Text = base.curParameter.strMMSSeries;
            this.lblMMSSerialPwd.Text = base.curParameter.strMMSSerialPwd;
            this.ckbIsAutoSendSMSByMemRegister.Checked = base.curParameter.bolAutoSendSMSByMemRegister;
            this.ckbIsAutoSendMMSByMemRegister.Checked = base.curParameter.bolAutoSendMMSByMemRegister;
            this.ckbIsAutoSendSMSByMemRecharge.Checked = base.curParameter.bolAutoSendSMSByMemRecharge;
            this.ckbIsAutoSendSMSByMemWithdraw.Checked = base.curParameter.bolAutoSendSMSByMemWithdraw;
            this.ckbIsAutoSendSMSByMemGiftExchange.Checked = base.curParameter.bolAutoSendSMSByMemGiftExchange;
            this.ckbIsAutoSendSMSByMemPointChange.Checked = base.curParameter.bolAutoSendSMSByMemPointChange;
            this.ckbIsAutoSendSMSByCommodityConsumption.Checked = base.curParameter.bolAutoSendSMSByCommodityConsumption;
            this.ckbIsAutoSendSMSByFastConsumption.Checked = base.curParameter.bolAutoSendSMSByFastConsumption;
            this.ckbIsAutoSendSMSByMemRedTimes.Checked = base.curParameter.bolAutoSendSMSByMemRedTimes;
            this.ckbIsAutoSendSMSByTimingConsumption.Checked = base.curParameter.bolAutoSendSMSByTimingConsumption;
            this.ckbIsAutoSendSMSByStorageTiming.Checked = base.curParameter.IsAutoSendSMSByStorageTiming;
            this.chkMarketingSMS.Checked = base.curParameter.bolMarketingSMS;
            this.txtMarketingSMS.Text = base.curParameter.strMarketingSmsSeries;
            this.lblMarketingSMSPwd.Text = base.curParameter.strMarketingSmsSerialPwd;
        }

        protected void btnExtraParameter_Click(object sender, EventArgs e)
        {
            Chain.Model.SysParameter modelParameter = new Chain.Model.SysParameter();
            modelParameter.ParameterID = 1;
            modelParameter.Sms = this.chkSms.Checked;
            modelParameter.MoneySms = this.chkMoneySms.Checked;
            modelParameter.IsSmsShopName = this.chkIsSmsShopName.Checked;
            modelParameter.SmsShopName = this.txtSmsShopName.Text.Trim();
            if (this.chkSms.Checked & (this.txtNotificationSMS.Text.Trim() == ""))
            {
                base.OutputWarn("开启短信必须填写短信序列号！");
            }
            modelParameter.SmsSeries = this.txtNotificationSMS.Text.Trim();
            modelParameter.SmsSerialPwd = (this.txtNotificationSMSPwd.Text.Trim() == "") ? base.curParameter.strNotificationSMSPwd : this.txtNotificationSMSPwd.Text.Trim();
            modelParameter.MMS = this.chkMMS.Checked;
            modelParameter.MMSSeries = this.txtMMSSeries.Text.Trim();
            modelParameter.MMSSerialPwd = (this.txtMMSSeriesPwd.Text.Trim() == "") ? base.curParameter.strMMSSerialPwd : this.txtMMSSeriesPwd.Text.Trim();
            modelParameter.Tel = this.chkTel.Checked;
            modelParameter.TelNoMember = this.chkTelNoMember.Checked;
            modelParameter.IsAutoSendSMSByMemRegister = this.ckbIsAutoSendSMSByMemRegister.Checked;
            modelParameter.IsAutoSendMMSByMemRegister = this.ckbIsAutoSendMMSByMemRegister.Checked;
            modelParameter.IsAutoSendSMSByMemRecharge = this.ckbIsAutoSendSMSByMemRecharge.Checked;
            modelParameter.IsAutoSendSMSByMemWithdraw = this.ckbIsAutoSendSMSByMemWithdraw.Checked;
            modelParameter.IsAutoSendSMSByMemGiftExchange = this.ckbIsAutoSendSMSByMemGiftExchange.Checked;
            modelParameter.IsAutoSendSMSByMemPointChange = this.ckbIsAutoSendSMSByMemPointChange.Checked;
            modelParameter.IsAutoSendSMSByCommodityConsumption = this.ckbIsAutoSendSMSByCommodityConsumption.Checked;
            modelParameter.IsAutoSendSMSByFastConsumption = this.ckbIsAutoSendSMSByFastConsumption.Checked;
            modelParameter.IsAutoSendSMSByMemRedTimes = this.ckbIsAutoSendSMSByMemRedTimes.Checked;
            modelParameter.IsAutoSendSMSByTimingConsumption = this.ckbIsAutoSendSMSByTimingConsumption.Checked;
            modelParameter.IsAutoSendSMSByStorageTiming = this.ckbIsAutoSendSMSByStorageTiming.Checked;
            if (this.chkMarketingSMS.Checked & (this.txtMarketingSMS.Text.Trim() == ""))
            {
                base.OutputWarn("开启营销短信必须填写短信序列号！");
            }
            modelParameter.MarketingSMS = this.chkMarketingSMS.Checked;
            modelParameter.MarketingSmsSeries = this.txtMarketingSMS.Text.Trim();
            modelParameter.MarketingSmsSerialPwd = (this.txtMarketingSMSPwd.Text.Trim() == "") ? base.curParameter.strMarketingSmsSerialPwd : this.txtMarketingSMSPwd.Text.Trim();
            Chain.BLL.SysParameter bllUpdateParameter = new Chain.BLL.SysParameter();
            if (bllUpdateParameter.UpdateExtraParameter(modelParameter))
            {
                PubFunction.curParameter = new PubFunction().LoadSysParameter();
                base.curParameter = PubFunction.curParameter;
                PubFunction.SaveSysLog(base._UserID, 3, "增值服务-参数设置", "增值服务的参数设置成功", base._UserShopID, DateTime.Now, PubFunction.ipAdress);
                base.OutputWarn("保存成功！");
            }
            else
            {
                base.OutputWarn("系统异常，未保存数据，请再次点击保存！");
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                this.BindParameter();
            }
        }
    }


